package innersort;

/*
 *  选择排序
 * */
public class SelectSort extends BaseSort {
    public static void main(String[] args) {
        int[] array = {2, 23, 25, 35, 1, 7, 9, 22, 25, 23, 16, 28, 30};
        sort(array);
    }

    public static void sort(int[] array) {
        for (int i = 0; i < array.length - 1; i++) {
            int min = i + 1;
            for (int j = min; j < array.length; j++) {
                if (array[j] < array[min]) {
                    min = j;
                }
            }

            if (array[i] > array[min]) {
                exchange(array, i, min);
            }
            print(array, i, min);
        }
    }
}
